package classe;
import java.sql.SQLException;
import java.sql.Statement;


import basedonnee.DBCon;
public class ConnexPlat {
	int plat_id;
	String plat_lib;
	String categ_lib;
	String prix;
	String desc_lib;
	
	public ConnexPlat(){
		this.plat_lib = "";
		this.categ_lib ="";
		this.prix = "";
		this.desc_lib = "";
		
	}
	public ConnexPlat(int plat_id, String plat_lib, String categ_lib,
			String prix, String desc_lib) {
		super();
		this.plat_id = plat_id;
		this.plat_lib = plat_lib;
		this.categ_lib = categ_lib;
		this.prix = prix;
		this.desc_lib = desc_lib;
	}
	
	public ConnexPlat( String plat_lib, String categ_lib, String prix,  String desc_lib) {
		super();
		this.plat_lib = plat_lib;
		this.categ_lib = categ_lib;
		this.prix = prix;
		this.desc_lib = desc_lib;
	}
	

	
	 public int getPlat_id() {
		return plat_id;
	}
	public void setPlat_id(int plat_id) {
		this.plat_id = plat_id;
	}
	public String getPlat_lib() {
		return plat_lib;
	}
	public void setPlat_lib(String plat_lib) {
		this.plat_lib = plat_lib;
	}
	public String getCateg_lib() {
		return categ_lib;
	}
	public void setCateg_lib(String categ_lib) {
		this.categ_lib = categ_lib;
	}
	public String getPrix() {
		return prix;
	}
	public void setPrix(String prix) {
		this.prix = prix;
	}
	public String getDesc_lib() {
		return desc_lib;
	}
	public void setDesc_lib(String desc_lib) {
		this.desc_lib = desc_lib;
	}
	
	
//	String up = " update \"Plat\" set ";
//	up += " \"Nom_Plat\" = "+this.getPlat_lib();

//****************************Inserer les plats dans la base de donnee***********************************//
public boolean storePlat (DBCon _dbCon)
	{
		boolean bRes = true;
		String zQuery = "INSERT INTO \"Plat\" (\"ID_Plat\",\"Nom_Plat\",\"Categ_Plat\",\"Prix_Plat\",\"Descrip_Plat\") VALUES (nextval('seqplat'), " ;
		zQuery +=  "'"+this.getPlat_lib() + "', " ;
		zQuery +=  "'"+this.getCateg_lib() + "', " ;
		zQuery += "'"+this.getPrix()+"', ";
		zQuery += "'"+this.getDesc_lib()+"') ";
		
		try
		{
			Statement st = _dbCon.connection.createStatement();	
			st.executeUpdate (zQuery) ;
		}
		catch (SQLException _e)
		{
			System.out.println ("Erreur interne pendant la mise Ã  jour !") ;
			bRes = false;
			_e.printStackTrace () ;
		}

		return bRes;
		
	}
	
}
	  